package com.travel.service.impl;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.travel.base.BaseDao;
import com.travel.base.impl.BaseServiceImpl;
import com.travel.bean.Ticket;
import com.travel.dao.TicketDao;
import com.travel.service.TicketService;
import com.travel.utils.PageHelper;
@Service("ticketServiceImpl")
public class TicketServiceImpl extends BaseServiceImpl<Ticket> implements TicketService {

	@Resource(name="ticketDaoImpl")
	private TicketDao ticketDaoImpl;

	@Override
	public BaseDao<Ticket> getBaseDao() {
		// TODO Auto-generated method stub
		return null;
	}
	/**
	 * 在首页分页展示数据
	 */
	@Override
	public PageHelper tacketList(Map map, Integer pageNum, Integer pageSize) {
		// TODO Auto-generated method stub
		PageHelper page=new PageHelper();
		page.setCurrentPageNo(pageNum);
		page.setPageSize(pageSize);
		page.setTotalCount(ticketDaoImpl.queryByPageCount(map));
		List<Ticket> listt=ticketDaoImpl.queryByPage(map, pageNum, pageSize);
		List<Map> listm=new ArrayList();
		for (Ticket ticket : listt) {
			Map mmap=new HashMap();
			mmap.put("id", ticket.getId());
			mmap.put("name", ticket.getName());
			mmap.put("price", ticket.getPrice());
			mmap.put("info", ticket.getInfo());
			mmap.put("total", ticket.getViewCount());
			mmap.put("picpath", ticket.getPicture().getPath());
			mmap.put("picname", ticket.getPicture().getName());
			listm.add(mmap);
		}
		page.setList(listm);
		return page;
	}
	/**
	 * 按照路线id查询票
	 */
	@Override
	public Ticket getTicketByRouteId(Integer routeId) {
		// TODO Auto-generated method stub
		return ticketDaoImpl.getTicketByRouteId(routeId);
	}

}
